Buffer API topic

This API requires the data to be buffered up-front - e.g., in the form of a Uint8List.

If all you need is a digest and your data is typically small (i.e., under kXXH3SmallDataSize), you will almost certainly want the buffer API for performance reasons (it is also simpler!).

You can use the xxh3 function as a Dart equivalent for the following xxHash C functions:

  • XXH3_64bits
  • XXH3_64bits_withSecret
  • XXH3_64bits_withSeed
  • XXH3_64bits_withSecretandSeed

Any implied semantics of calling one of the above functions are automatically handled based on which parameters are supplied or not supplied; e.g., calling xxh3 with just a secret and not specifying a seed is equivalent to calling XXH3_64bits_withSecret in C, and so on...

Constants

kSecretSizeMin → const int Buffer API Stream API
The absolute minimum size for a custom secret as defined in XXH3. See https://github.com/Cyan4973/xxHash/blob/b1a61dff654af43552b5ee05c737b6fd2a0ee14b/xxhash.h#L931
kXXH3HashLongFunction64Bit → const HashLongFunction Buffer API
The default HashLongFunction from xxHash. See HashLongFunction.
kXXH3SmallDataSize → const int Buffer API Stream API
The maximum size, in bytes, of a 'short' key. This is known internally to XXH3 as the 'mid-size max'.

Functions

xxh3(Uint8List input, {Uint8List? secret, int seed = 0, HashLongFunction hashLongFunction = kXXH3HashLongFunction64Bit}) int Buffer API
Perform an XXH3 hash of the input data. The input data is provided as a Uint8List to avoid having to perform conversions internally.
xxh3String(Uint8List input, {Uint8List? secret, int seed = 0, HashLongFunction hashLongFunction = kXXH3HashLongFunction64Bit}) String Buffer API
A convenience wrapper for xxh3 that returns the result, formatted as an unsigned hexadecimal string.

Typedefs

HashLongFunction = int Function(ByteData input, int seed, ByteData secret) Buffer API
When hashing inputs of length greater than 240, the HashLongFunction is used. The default is kXXH3HashLongFunction64Bit.